package com.yoomiito.app.ui.order.detail;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.yoomiito.app.Constant;
import com.yoomiito.app.R;
import com.yoomiito.app.base.BaseActivity;
import com.yoomiito.app.model.order.OrderDetailGoods;
import com.yoomiito.app.utils.AllUtils;
import com.yoomiito.app.utils.YMToast;

import butterknife.BindView;
import butterknife.OnClick;

public class WuLIuActivity extends BaseActivity {

    @BindView(R.id.act_wuliu_rcy)
    RecyclerView mRecyclerView;
    @BindView(R.id.tv_center)
    TextView titleTv;
    @BindView(R.id.item_wuliu_company)
    TextView companyTv;
    @BindView(R.id.item_wuliu_order)
    TextView wuliuIdTv;
    @BindView(R.id.item_order_new_info)
    TextView newWuLiuTv;
    @BindView(R.id.item_wuliu_iv)
    ImageView arrowIv;

    private OrderDetailGoods mDetailInfo;
    @Override
    public int getLayoutId() {
        return R.layout.act_wuliu;
    }

    @Override
    public Object newP() {
        return null;
    }

    public static void start(Context context, OrderDetailGoods wuliuInfo){
        Intent intent = new Intent(context,WuLIuActivity.class);
        intent.putExtra(Constant.DATA,wuliuInfo);
        context.startActivity(intent);
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        titleTv.setVisibility(View.VISIBLE);
        titleTv.setText("追踪物流");
        mDetailInfo = getIntent().getParcelableExtra(Constant.DATA);
        arrowIv.setVisibility(View.GONE);
        companyTv.setText("物流公司："+mDetailInfo.getExpress_company());
        wuliuIdTv.setText("快递单号："+mDetailInfo.getTrack_no());
        newWuLiuTv.setVisibility(View.INVISIBLE);

        LinearLayoutManager manager = new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false);
        mRecyclerView.setLayoutManager(manager);
        WuLIuAdapter wuLIuAdapter = new WuLIuAdapter(mDetailInfo.getExpressInfo());
        mRecyclerView.setAdapter(wuLIuAdapter);

    }

    @OnClick({R.id.iv_back_left,R.id.item_wuliu_order_copy})
    public void onClick(View view){
        switch (view.getId()){
            case R.id.iv_back_left:
                finish();
                break;
            case R.id.item_wuliu_order_copy:
                AllUtils.copyText(this,mDetailInfo.getTrack_no());
                YMToast.showText("复制成功");
                break;
        }
    }
}
